import { request } from '@/utils/http'
import {Message} from 'element-ui'

const dashboard = {
  namespaced: true,
  state: {
    weatherNowVo: [],
    weatherTodayVoList: [],
    weatherForecastVolist: [],
    monthData:null
  },
  mutations: {
    SAVE_WEATHER(state, payload) {
      state.weatherNowVo = payload.weatherNowVo;
      state.weatherTodayVoList = payload.weatherTodayVoList;
      state.weatherForecastVolist = payload.weatherForecastVolist
    },
    SAVE_DATA_OVERVIEW(state,payload){
      state.dataOverview = payload
    }
  },
  actions: {
    FETCH_WEATHER(commit) {
      request({
        url: "/farmland/mock/timeWeather"
      }).then(res => {
        if (res.code === 1) {
         commit('SAVE_WEATHER',res.daat.weather)
          return
        }
        Message.error(res.msg)
      })
    },
    FETCH_DATA_OVERVIEW(){
      request({
        url:'farmland/mock/dataOverview'
      }).then(res=>{
        console.log(res)
      })
    }
  }
}

export default dashboard